package com.aquila.bible.system;

import java.util.Calendar;

import com.aquila.bible.SuggestObject;
import com.util.mail.MailSenderInfo;
import com.util.mail.SimpleMailSender;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;

public class Utils {
	public static int getDeviceScreenWidth(Context context){
    	DisplayMetrics dm = context.getResources().getDisplayMetrics();
    	return dm.widthPixels;
    }
    public static int getDeviceScreenHeight(Context context){
    	DisplayMetrics dm = context.getResources().getDisplayMetrics();
    	return dm.heightPixels;
    }
    /**
     * 设置屏幕全屏
     * @param context
     */
    public static void setFullScreen(Activity context){
    	context.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    			WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        context.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    
    
    public static final int NETWORN_NONE = 0;
	public static final int NETWORN_WIFI = 1;
	public static final int NETWORN_MOBILE = 2;
	public static int getNetworkState(Context context) {
		ConnectivityManager connManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);

		// Wifi
		State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
				.getState();
		if (state == State.CONNECTED || state == State.CONNECTING) {
			return NETWORN_WIFI;
		}

		// 3G
		state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
				.getState();
		if (state == State.CONNECTED || state == State.CONNECTING) {
			return NETWORN_MOBILE;
		}
		return NETWORN_NONE;
	}
	
	
	/**
	 * 发送错误信息的邮件
	 * @param e
	 *2012-7-19 上午10:43:00
	 */
	public static void sendMail(String subject, String content){
		MailSenderInfo mailInfo = new MailSenderInfo();
		mailInfo.setMailServerHost("smtp.126.com");
		mailInfo.setMailServerPort("25");
		mailInfo.setValidate(true);
			
		mailInfo.setUserName("tianlan198889") ;
		mailInfo.setFromAddress("tianlan198889@126.com");
		mailInfo.setPassword("123456");// 您的邮箱密码
		mailInfo.setToAddress("biblefeedback@gmail.com");
		mailInfo.setSubject(subject);
		mailInfo.setContent(content);
		
		// 这个类主要来发送邮件
		SimpleMailSender sms = new SimpleMailSender();
		sms.sendTextMail(mailInfo);// 发送文体格式
	}	
	
	
}
